<?php use_helper('PA_Links') ?>
<?php if(isset($demands) ? ($demands->count() > 0 ? true : false ) : false): ?>
  <table id="inline_table">
    <tr>
    <th> Lp. </th>
    <th> Symbol </th>
    <th> Projekt </th>
    <th> Opis </th>
    <th> Użytkownik </th>
    <th> Kategoria / Kontrahent</th>
    <th> Utworzono </th>
    <th> Edycja i narzędzia</th>
    </tr>
  <?php foreach($demands as $demand): ?>
    <tr>
      <td><p id="counter"></p></td>
      <td nowrap="nowrap">
        <a onclick="App.loadWindow('<?php echo link_to_app('Production', 'showDemand', array('id' => $demand->getId())) ?>')" class="middle"><?php echo $demand->getNumber() ?></a>
      </td>
      <td nowrap="nowrap"><?php echo $demand->getProject()." [".$demand->getProject()->getShortcut()."]" ?></td>
      <td><?php echo $demand->getDescription() ?></td>
      <td nowrap="nowrap"><?php echo $demand->getUser()." [".$demand->getUserId()."]" ?></td>
      <td><?php echo ($demand->getCategory() == "" ? $demand->getDeliverer() : $demand->getCategory())  ?></td>
      <td nowrap="nowrap"><?php echo $demand->getCreatedAt() ?></td>
      <td nowrap="nowrap">
        <a href="<?php echo link_to_app('Store', 'createOrder', array('demand' => $demand->getId())) ?>" class="middle">Zamów</a>
        <?php if($sf_user->hasCredential('admin')): ?>
        <img src="/images/icons/delete.png" class="middle" width="16" height="16"/>  <a href="<?php echo link_to_app('Production', 'deleteDemand', array('id' => $demand->getId())) ?>" class="middle">Usuń</a>
        <?php else: ?>
        <img src="/images/icons/delete_inactive.png" class="middle" width="16" height="16"/> <a class="middle">Usuń</a>
        <?php endif; ?>
      </td>
    </tr>
  <?php endforeach; ?>
  </table>
<?php else: ?>
Brak dokumentów.
<?php endif; ?>
